import {
	defineStore,
} from 'pinia';

// 定义仓库有两种定义方式

// 01 选项options方式
export const useCounterStore = defineStore('counter', {
	// 定义状态
	state: () => ({
		count: 5,
		currentTab: 2,
	}),
	// 计算数据
	getters: {
		doubleCount: (state) => state.count * 2,
		getCurrentTab: (state) => state.currentTab,
	},
	// 动作支持异步
	actions: {
		setCount(v) {
			this.count = v;
		},
		changeCurrentTab(v) {
			this.currentTab = v;
		},
	},
});
